<template>
  <div>

    <a-spin :spinning="confirmLoading" style="background: #fff">
      <j-form-container :disabled="false">
        <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
          <a-collapse v-model="activeKey">
            <!-- 基本信息 -->
            <a-collapse-panel key="1" header="基本信息">
              <a-row :gutter="48">
                <a-col :span="8" :hidden="true">
                  <a-form-model-item label="标题" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bpmBizTitle">
                    <a-input :disabled="formDisabled" v-model="model.bpmBizTitle" placeholder="请输入标题" ></a-input>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="单据编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="billNo">
                    <a-input v-model="model.billNo" placeholder="请输入单据编号" disabled></a-input>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="申请人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="proposer">
                    <select-user-by-dep
                      placeholder="请选择申请人"
                      v-model="model.proposer"
                      disabled/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="申请部门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="proposerDeptId">
                    <j-select-depart placeholder="请选择申请部门" v-model="model.proposerDeptId" disabled/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="申请时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="createTime">
                    <j-date
                      placeholder="请选择申请时间"
                      v-model="model.createTime"
                      :show-time="true"
                      date-format="YYYY-MM-DD HH:mm:ss"
                      style="width: 100%"
                      disabled/>
                  </a-form-model-item>
                </a-col>
                <!-- <a-col :span="8">
                  <a-form-model-item label="申请单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="applicant">
                    <j-select-depart placeholder="请选择申请单位" :disabled="formDisabled" v-model="model.applicant" />
                  </a-form-model-item>
                </a-col> -->
                <a-col :span="8">
                  <a-form-model-item label="费用所属团队" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="teamId">
                    <select-team-input :proposerDeptId="proposerDeptId" isApi="expenseReimbursement" placeholder="请选择费用所属团队" :disabled="formDisabled || showFlowSubmitButton" v-model="model.teamId" :tdlx="3" @back="teamBack" />
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="申请公司" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="companyId">
                    <select-Company-input placeholder="请选择申请公司" :disabled="formDisabled || showFlowSubmitButton" v-model="model.companyId" @back="companyBack"/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="出差人员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="employeeId">
                    <select-user-by-dep
                      placeholder="请选择出差人员"
                      :multi="true"
                      :disabled="formDisabled || showFlowSubmitButton"
                      v-model="model.employeeId" />
                  </a-form-model-item>
                </a-col>
                <!-- <a-col :span="8">
                  <a-form-model-item label="是否外聘人员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isExternalEngagedEmployee">
                    <j-dict-select-tag :disabled="formDisabled" v-model="model.isExternalEngagedEmployee" dictCode="YES_OR_NO" placeholder="请选择是否外聘人员" @input="employeeInput"/>
                  </a-form-model-item>
                </a-col> -->
                <!-- <a-col :span="8">
                  <a-form-model-item label="外聘人员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="externalPersonnel">
                    <a-input :disabled="employeeFlag" v-model="model.externalPersonnel" placeholder="请输入外聘人员，多人用逗号分割"  ></a-input>
                  </a-form-model-item>
                </a-col> -->
                <a-col :span="8">
                  <a-form-model-item label="单据类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="billCategory">
                    <j-dict-select-tag :disabled="formDisabled || showFlowSubmitButton" type="list" v-model="model.billCategory" dictCode="bill_category" placeholder="请选择单据类型" />
                  </a-form-model-item>
                </a-col>

                <a-col :span="8" v-if="model.teamYear=='2023'">
                  <a-form-model-item label="费用所属年度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="teamYear">
                    <j-dict-select-tag placeholder="请选择费用所属年度" v-model="model.teamYear" dictCode="tdnd_type" disabled/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="本次支付金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="currentPaymentAmount">
                    <a-input-number
                      disabled
                      v-model="model.currentPaymentAmount"
                      placeholder="请输入本次支付金额"
                      style="width: 100%"/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="本次累计冲账金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="chargedAmount">
                    <a-input v-model="model.chargedAmount" placeholder="请输入本次累计冲账金额" disabled></a-input>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="团队费用类别" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="teamFeeCategory">
                    <j-dict-select-tag :disabled="formDisabled" type="list" v-model="model.teamFeeCategory" dictCode="team_fee_category" placeholder="请选择团队费用类别" />
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="是否关联项目" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isRelProject">
                    <j-dict-select-tag
                      :disabled="formDisabled || showFlowSubmitButton"
                      type="radio"
                      v-model="model.isRelProject"
                      dictCode="YES_OR_NO"
                      placeholder="请选择是否关联项目"
                      @input="projectInput"/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="是否使用商务卡" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isUseBusinessCard">
                    <j-dict-select-tag
                      :disabled="formDisabled || showFlowSubmitButton"
                      type="radio"
                      v-model="model.isUseBusinessCard"
                      dictCode="YES_OR_NO"
                      placeholder="请选择是是否使用商务卡"
                    />
                  </a-form-model-item>
                </a-col>
                <a-col :span="24">
                  <a-form-model-item label="出差事由" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="travelReasons">
                    <a-textarea :disabled="formDisabled" :max-length="500" v-model="model.travelReasons" rows="4" placeholder="请输入出差事由"/>
                  </a-form-model-item>
                </a-col>
              </a-row>
            </a-collapse-panel>
            <!-- 报销详情 -->
            <a-collapse-panel key="2" header="报销详情">
              <a-row :gutter="48">
                <erp-finance-travel-detail-list
                  ref="travelDetails"
                  :disabled="formDisabled"
                  @travelDetailData="travelDetailData"
                  :teamId="model.teamId"
                  :companyId="model.companyId"
                  :showFlowSubmitButton="showFlowSubmitButton"
                  :isRelProject="model.isRelProject"
                  @syncAdd="syncAdd"/>
                <div>
                  <span>
                    <span style="margin-left: 23px;font-weight: bold;">报销明细费用累计：{{ model.reimbursementAmount }}元</span>
                    （注：本次报销实际支付金额为报销明细费用累计。）
                  </span>
                </div>
              </a-row>
            </a-collapse-panel>
            <!-- 自驾公里数补助明细 -->
            <a-collapse-panel key="3" header="自驾公里数补助明细">
              <a-row :gutter="48">
                <erp-finance-reimbursement-detail-list
                  ref="travelReimbursements"
                  :disabled="formDisabled"
                  :teamId="model.teamId"
                  :companyId="model.companyId"
                  :showFlowSubmitButton="showFlowSubmitButton"
                  :isRelProject="model.isRelProject"
                  @travelReimbursementData="travelReimbursementData" />
                <div>
                  <span>
                    <span style="margin-left: 23px;font-weight: bold;">自驾公里数补助明细费用累计：{{ model.kilometresAmount }}元</span>
                    （注：自驾公里数补助累计不计入本次报销金额，使用油卡和定额提现方式兑现。）
                  </span>
                </div>
              </a-row>
            </a-collapse-panel>
            <!-- 结算信息 -->
            <a-collapse-panel key="4" header="结算信息">
              <a-row :gutter="48" style="min-height: 140px;">
                <a-col :span="24">
                  <a-form-model-item label="结算方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="settleType">
                    <j-dict-select-tag
                      :disabled="formDisabled || showFlowSubmitButton"
                      type="list"
                      @input="settleTypeInput"
                      v-model="model.settleType"
                      dictCode="settle_type_all"
                      placeholder="请选择结算方式"
                      style="width: 29.7%"/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="16" :hidden="true">
                  <a-form-model-item label="报销明细费用累计 + 自驾公里数补助明细费用累计 = 本次累计报销金额" :labelCol="labelCol" :wrapperCol="wrapperCol">
                    <a-input v-model="model.reimbursementAmount" disabled style="width: 30%"></a-input>
                    &nbsp;+&nbsp;
                    <a-input v-model="model.kilometresAmount" disabled style="width: 30%"></a-input>
                    &nbsp;=&nbsp;
                    <a-input v-model="model.thisAmount" disabled style="width: 30%"></a-input>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8" v-if="transferAccounts">
                  <a-form-model-item label="收款员工" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="payeeName">
                    <select-user-by-dep
                      :disabled="formDisabled || showFlowSubmitButton"
                      :multi="false"
                      v-model="model.payeeName"
                      @back="selectAccountName"></select-user-by-dep>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8" v-if="transferAccounts">
                  <a-form-model-item label="开户行联行号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cnapsCode">
                    <a-input v-model="model.cnapsCode" placeholder="请输入开户行联行号" disabled></a-input>
                  </a-form-model-item>
                </a-col>
                <!-- <a-col :span="8" v-if="transferAccounts">
                  <a-form-model-item label="收款户名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accountName">
                    <a-input :disabled="formDisabled || showFlowSubmitButton" v-model="model.accountName" placeholder="请输入收款户名"  ></a-input>
                  </a-form-model-item>
                </a-col> -->
                <a-col :span="8" v-if="transferAccounts">
                  <a-form-model-item label="收款开户行" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bankName">
                    <a-input :disabled="formDisabled || showFlowSubmitButton" v-model="model.bankName" placeholder="请输入收款开户行" disabled></a-input>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8" v-if="transferAccounts">
                  <a-form-model-item label="收款账号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accountNo">
                    <a-input :disabled="formDisabled || showFlowSubmitButton" :max-length="32" v-model="model.accountNo" placeholder="请输入收款账号" disabled></a-input>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8" v-if="strikeBalance && !formDisabled">
                  <a-form-model-item label="关联借款申请" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="loanBillId">
                    <select-finance-loan-bill-input :disabled="formDisabled || !model.teamId || !model.companyId" :teamId="model.teamId" :applicant="model.companyId" v-model="model.loanBillId" @back="back"/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8" v-if="strikeBalance && formDisabled">
                  <a-form-model-item label="关联借款申请" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="loanBillId">
                    <a-input
                      :readOnly="true"
                      :disabled="!model.loanBillId_dictText"
                      v-model="model.loanBillId_dictText"
                      style="color: #1890FF;"
                      placeholder="请选择关联借款申请"
                      @click.prevent="loanBillClick(model.loanBillId)"></a-input>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8" v-if="strikeBalance">
                  <a-form-model-item label="未还金额（元）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="outstandingAmount">
                    <a-input v-model="model.outstandingAmount" placeholder="请输入未还金额" disabled></a-input>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8" v-if="strikeBalance">
                  <a-form-model-item label="支付金额（元）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="paymentAmount">
                    <a-input v-model="model.paymentAmount" placeholder="请输入支付金额" disabled></a-input>
                  </a-form-model-item>
                </a-col>

                <a-col :span="8">
                  <a-form-model-item label="冲账单据类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="relBillType">
                    <j-dict-select-tag
                      :disabled="formDisabled || showFlowSubmitButton"
                      type="list"
                      v-model="model.relBillType"
                      dictCode="bill_type"
                      placeholder="请选择冲账单据类型"
                      @input="radioChange" />
                  </a-form-model-item>
                </a-col>
                <a-col :span="24">
                  <template v-if="model.relBillType=='1'">
                    <div>
                      <div style="margin-bottom: 6px;margin-top: 6px;" >
                        <a-button @click="handleChargedInfoAdd" v-if="!formDisabled && !showFlowSubmitButton" type="primary">新增</a-button>
                      </div>
                      <a-table
                        ref="table"
                        size="middle"
                        rowKey="id"
                        :loading="loading"
                        :columns="chargedLoanColumns"
                        :pagination="false"
                        :data-source="chargedInfoData"
                        :scroll="{x: true}"
                      >
                        <span slot="relBillId" slot-scope="text, record">
                          <a @click="goDetail(record.relBillId)">{{ loadBillDetail(text) }}</a>
                        </span>
                        <span slot="action" slot-scope="text, record">
                          <template v-if="!formDisabled">
                            <a-button
                              class="ruleButton"
                              :ghost="true"
                              type="primary"
                              icon="edit"
                              @click="handleChargedInfoEdit(record)"/>
                            <template v-if="!showFlowSubmitButton">
                              <a-divider type="vertical"/>
                              <a-popconfirm title="确定删除吗?" @confirm="() => handleChargedInfoDelete(record.id)">
                                <a-button
                                  class="ruleButton"
                                  :ghost="true"
                                  type="primary"
                                  icon="delete"
                                />
                              </a-popconfirm>
                            </template>
                          </template>
                        </span>
                      </a-table>
                    </div>
                  </template>
                </a-col>
                <!--              <a-col :span="24">-->
                <!--                <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">-->
                <!--                  <a-textarea :disabled="formDisabled" :max-length="500" v-model="model.remark" rows="4" placeholder="请输入备注"/>-->
                <!--                </a-form-model-item>-->
                <!--              </a-col>-->
              </a-row>
            </a-collapse-panel>
            <!-- 附件信息 -->
            <a-collapse-panel key="5" header="附件信息">
              <a-row :gutter="48">
                <a-col :span="24">
                  <a-form-model-item prop="attachments">
                    <j-upload :disabled="formDisabled" v-model="model.attachments"></j-upload>
                    <!-- <a-button v-else icon="download" @click="viewFile(model.attachments)">文件列表</a-button> -->
                  </a-form-model-item>
                </a-col>
              </a-row>
            </a-collapse-panel>
            <!-- <a-col v-if="showFlowSubmitButton" :span="24" style="text-align: center">
              <a-button @click="submitForm">提 交</a-button>
            </a-col> -->
          </a-collapse>
        </a-form-model>
        <common-flow-list v-if="formBpm && model.bpmStatus !== '1'" :formData="formData" style="margin-top: 10px"></common-flow-list>
        <view-file-modal ref="viewFileModal"></view-file-modal>
        <a-modal
          :visible="projectVisible"
          title="提示"
          :centered="false"
          @ok="handleOk"
          @cancel="handleCancel"
          :bodyStyle="{
            'height':'100px',
            'display':'flex',
            'justifyContent': 'center',
            'alignItems': 'center'
          }">
          <p>
            你确定要切换是否关联项目？如果切换则会清除报销详情和自驾公里数补助明细中已填写的所有信息。
          </p>
        </a-modal>
      </j-form-container>
      <a-row :gutter="48">
        <a-col :span="24" style="text-align: center;margin-top: 15px">
          <a-button type="primary" v-if="formBpm" :style="{ marginRight: showFlowSubmitButton?'10px':'0px' }" @click="onPrint">打印</a-button>
          <a-button @click="submitForm('submit')" v-if="showFlowSubmitButton">提 交</a-button>
        </a-col>
      </a-row>
      <!-- 详情开始 -->
      <a-modal
        :maskClosable="false"
        title="详情"
        :width="1200"
        :bodyStyle="{
          padding: '0 24px'
        }"
        :visible="visibleDetail"
        @cancel="handleCancelDetail"
        cancelText="关闭">
        <erp-finance-loan-bill-form ref="realForm" :disabled="true" normal></erp-finance-loan-bill-form>
        <template slot="footer">
          <a-button @click.stop="handleCancelDetail">关闭</a-button>
        </template>
      </a-modal>
      <erp-finance-reimbursement-charged-bill-info-modal ref="chargedInfo" @ok="modalChargedInfoFormOk" :relBillType="model.relBillType" :showFlowSubmitButton="showFlowSubmitButton" :applicant="model.companyId"> </erp-finance-reimbursement-charged-bill-info-modal>
      <ErpFinanceLoanBillPenetrate ref="loanBillPenetrate"></ErpFinanceLoanBillPenetrate>
      <!-- 详情结束 -->
      <ErpFinanceTravelReimbursementBillFormPrint v-if="formBpm && isSubmit" class="print_style" id="travelContent" :formData="model1" :formDataHistory="formData"></ErpFinanceTravelReimbursementBillFormPrint>
    </a-spin>
  </div>
</template>

<script>

import { httpAction, getAction } from '@/api/manage'
import { viewFile } from '@/utils/util'
import ViewFileModal from '@/views/scy/components/ViewFileModal'
import { mapGetters } from 'vuex';
import moment from 'moment';
import SelectUserByDep from '@/views/scy/components/SelectUserByDep'
import ErpFinanceReimbursementDetailList from './reference/ErpFinanceReimbursementDetailList';
import ErpFinanceTravelDetailList from './reference/ErpFinanceTravelDetailList';
import SelectFinanceLoanBillInput from '@/views/scy/components/SelectFinanceLoanBillInput'// 关联借款单
import SelectTeamInput from '@/views/scy/components/SelectTeamInput'
import SelectCompanyInput from '@/views/scy/components/SelectCompanyInput'
import ErpFinanceLoanBillForm from '@/views/erp/finance/borrow/modules/ErpFinanceLoanBillForm'
import { Decimal } from 'decimal.js'
import CommonFlowList from '@/views/components/CommonFlowList.vue';
import ErpFinanceTravelReimbursementBillFormPrint from './ErpFinanceTravelReimbursementBillFormPrint'
import Print from '@/utils/print/printarea.js';
import { initDictOptions, filterMultiDictText } from '@/components/dict/JDictSelectUtil'
import ErpFinanceLoanBillPenetrate from '@/views/scy/penetrate/ErpFinanceLoanBillPenetrate'
import ErpFinanceReimbursementChargedBillInfoModal from './ErpFinanceReimbursementChargedBillInfoModal'
  export default {
    name: 'ErpFinanceTravelReimbursementBillForm',
    mixins: [viewFile],
    components: {
      SelectTeamInput,
      ViewFileModal,
      SelectUserByDep,
      ErpFinanceReimbursementDetailList,
      ErpFinanceTravelDetailList,
      SelectFinanceLoanBillInput,
      SelectCompanyInput,
      ErpFinanceLoanBillForm,
      CommonFlowList,
      ErpFinanceLoanBillPenetrate,
      ErpFinanceReimbursementChargedBillInfoModal,
      ErpFinanceTravelReimbursementBillFormPrint
    },
    props: {
      // 流程表单data
      formData: {
        type: Object,
        default: () => {},
        required: false
      },
      // 表单模式：true流程表单 false普通表单
      formBpm: {
        type: Boolean,
        default: false,
        required: false
      },
      // 表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      },
      // 是否詳情进入
      detail: {
        type: Boolean,
        default: false
      }
    },
    watch: {
      activeKey(key) {
        this.$forceUpdate()
      }
    },
    provide() {
			return {
				layout: this // 这里的this值当前组件实例
			}
		},
    data () {
      return {
        isSubmit: true,
        activeKey: ['1', '2', '3', '4', '5'],
        proposerDeptId:'',
        model: {
          billNo: null,
          checkStatus: 0,
          // isExternalEngagedEmployee: '0',
          isRelProject: '1',
          reimbursementAmount: 0,
          kilometresAmount: 0,
          thisAmount: 0,
          applyOilFilling: '0',
          travelDetail: [],
          reimbursementDetail: [],
          chargedInfoList: [],
          relBillType: '1'
          // teamYear: null
        },
        model1: {
          billNo: null,
          checkStatus: 0,
          // isExternalEngagedEmployee: '0',
          isRelProject: '1',
          reimbursementAmount: 0,
          kilometresAmount: 0,
          thisAmount: 0,
          applyOilFilling: '0',
          travelDetail: [],
          reimbursementDetail: [],
          chargedInfoList: [],
          relBillType: '1'
          // teamYear: null
        },
        labelCol: {
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 24 }
        },
        confirmLoading: false,
        validatorRules: {
          // isExternalEngagedEmployee: [
          //   { required: true, message: '请选择是否外聘人员!', trigger: 'blur'},
          // ],
          isRelProject: [
            { required: true, message: '请选择是否关联项目!', trigger: 'change' }
          ],
          isUseBusinessCard: [
            { required: true, message: '请选择是否使用商务卡!', trigger: 'change' }
          ],
          travelReasons: [
            { required: true, message: '请输入出差事由!', trigger: 'blur' }
          ],
          settleType: [
            { required: true, message: '请选择结算方式!', trigger: 'blur' }
          ],
          payeeName: [
            { required: true, message: '请输入收款员工!', trigger: 'blur' }
          ],
          accountName: [
            { required: true, message: '请输入收款户名!', trigger: 'blur' }
          ],
          cnapsCode: [
            { required: true, message: '请输入开户行联行号!', trigger: 'blur' }
          ],
          bankName: [
            { required: true, message: '请输入收款开户行!', trigger: 'blur' }
          ],
          accountNo: [
            { required: true, message: '请输入正确的银行卡号!', trigger: 'blur' }
            // { pattern: /^\d{10,25}$/,  message: '请输入正确的银行卡号!' },
          ],
          loanBillId: [
            { required: true, message: '请选择关联借款单!', trigger: 'change' }
          ],
          billCategory: [
            { required: true, message: '请选择单据类型!', trigger: 'blur' }
          ],
          teamId: [
            { required: true, message: '请选择费用所属团队!', trigger: 'change' }
          ],
          currentPaymentAmount: [
            { required: true, message: '请输入本次支付金额!', trigger: 'blur' },
            // 本次支付金额不允许小于零
            { required: true, pattern: /^(([0-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '金额不能小于零!' }
          ],
          companyId: [
            { required: true, message: '请选择所属公司!', trigger: 'change' }
          ],
          teamFeeCategory: [
              { required: true, message: '请选择团队费用类别!', trigger: 'blur' }
          ],
          employeeId: [
            { required: true, message: '请选择出差人员!', trigger: 'change' }
          ]
        },
        url: {
          queryFileById: '/api/erp/files/employee/erpEmployeeFile/queryFileById',
          add: '/api/erp/finance/travel/erpFinanceTravelReimbursementBill/add',
          edit: '/api/erp/finance/travel/erpFinanceTravelReimbursementBill/edit',
          queryById: '/api/erp/finance/travel/erpFinanceTravelReimbursementBill/queryById',
          gainBillNo: '/api/erp/finance/travel/erpFinanceTravelReimbursementBill/gainBillNo',
          queryFileById: '/api/erp/files/employee/erpEmployeeFile/queryFileById',
          queryByLoanBillId: '/api/erp/finance/borrow/erpFinanceLoanBill/queryById'
        },
        transferAccounts: false,
        strikeBalance: false,
        detailData: [],
        chargedInfoData: [],
        reimbursementData: [],
        // employeeFlag: true,
        projectFlag: false,
        projectVisible: false,
        teamIdBackups: null,
        companyIdBackups: null,
        tdnd: null,
        userName: '',
        visibleDetail: false,
        loading: false,
        dictOptions: [],
        chargedLoanColumns: [
          {
            title: '序号',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title: '冲账借款单据',
            align: 'center',
            dataIndex: 'relBillId',
            scopedSlots: { customRender: 'relBillId' }
          },
          {
            title: '借款金额(元)',
            align: 'center',
            dataIndex: 'borrowLoanAmount'
          },
          {
            title: '已还金额(元)',
            align: 'center',
            dataIndex: 'borrowOnloanAmount'
          },
          {
            title: '本次冲账金额(元)',
            align: 'center',
            dataIndex: 'chargedAmount'
          },
          {
            title: '剩余未冲账金额(元)',
            align: 'center',
            dataIndex: 'unChargedAmount'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            fixed: 'right',
            width: 147,
            scopedSlots: {
              filterDropdown: 'filterDropdown',
              filterIcon: 'filterIcon',
              customRender: 'action'
            }
          }
        ]
      }
    },
    computed: {
      formDisabled() {
        if (this.formBpm === true) {
          if (this.formData.disabled === false) {
            return false
          }
          return true
        }
        return this.disabled
      },
      showFlowSubmitButton() {
        if (this.formBpm === true) {
          if (this.formData.disabled === false) {
            return true
          }
        }
        return false
      }
    },
    async created () {
       // 备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
      // 如果是流程中表单，则需要加载流程表单data
      this.showFlowData();
      // 字典
      this.initDicts()
    },
    methods: {
      ...mapGetters(['userInfo']),
      // 选择人员
      selectAccountName() {
        let payeeName = this.model.payeeName
        getAction(this.url.queryFileById, { id: payeeName }).then(res => {
          if (res.success) {
            let result = res.result
            this.$set(this.model, 'bankName', result.bankName);
            this.$set(this.model, 'accountNo', result.bankCard);
            this.$set(this.model, 'cnapsCode', result.cnapsCode); // 开户行联行号
          }
        })
      },
      loadBillDetail(text) {
        if (!text) {
          return ''
        } else {
          return filterMultiDictText(this.dictOptions['relLoanBillId'], text + '')
        }
      },
      // 修改按钮
      radioChange (data) {
        if (data == undefined) {
          this.$set(this.model, 'relBillType', '');
        }
        if (!data) {
					this.$set(this.model, 'chargedAmount', '0.00');
          this.getCurrentPaymentAmount()
					this.$set(this.model, 'chargedInfoList', []);
				}
      },
      // 加载穿透表单
      goDetail(id) {
        if (this.model.relBillType == '1') {
          this.$refs.loanBillPenetrate.initData(id);
          this.$refs.loanBillPenetrate.visible = true;
        } else if (this.model.relBillType == '2') {
          this.$refs.paymentBillPenetrate.initData(id);
          this.$refs.paymentBillPenetrate.visible = true;
        } else if (this.model.relBillType == '3') {
          this.$refs.depositBillPenetrate.initData(id);
          this.$refs.depositBillPenetrate.visible = true;
        }
      },
      // 子表提交
      modalChargedInfoFormOk(data) {
        this.loading = true;
        let flag = true;
        for (let i = 0; i < this.chargedInfoData.length; i++) {
          if (this.chargedInfoData[i].id == data.id) {
            this.chargedInfoData.splice(i, 1, data);
            flag = false;
          }
        }
        if (flag) {
          this.chargedInfoData.push(data);
        }
        this.$refs.chargedInfo.handleDataSource(this.chargedInfoData);
        // 计算总金额
        this.handelCharedAmount()
        this.loading = false;
      },
      handelCharedAmount() {
        let chargedAmount = 0
        this.chargedInfoData.forEach(item => {
          chargedAmount += item.chargedAmount;
        })
        this.model.chargedAmount = chargedAmount.toFixed(2)
        this.getCurrentPaymentAmount()
      },
      // 冲账子表
      // 工资福利类子表新增
      handleChargedInfoAdd() {
        this.$refs.chargedInfo.add();
        this.$refs.chargedInfo.title = '新增';
        this.$refs.chargedInfo.disableSubmit = false;
        this.$refs.chargedInfo.handleDataSource(this.chargedInfoData);
      },
      // 子表编辑
      handleChargedInfoEdit(record) {
        this.$refs.chargedInfo.edit(record);
        this.$refs.chargedInfo.title = '修改';
        this.$refs.chargedInfo.disableSubmit = false;
        this.$refs.chargedInfo.handleDataSource(this.chargedInfoData);
      },
      // 子表复制行
      handleChargedInfoCopy(record) {
        let model = Object.assign({}, record);
        model.id = parseInt(Math.random() * 1000000000000);
        this.chargedInfoData.push(JSON.parse(JSON.stringify(model)))
        // 计算总金额
        this.handelCharedAmount()
      },
      // 子表删除
      handleChargedInfoDelete(id) {
        for (let i = 0; i < this.chargedInfoData.length; i++) {
          if (this.chargedInfoData[i].id == id) {
            this.chargedInfoData.splice(i, 1);
          }
        }
        // 计算总金额
        this.handelCharedAmount()
      },

      // 计算本次支付金额
      getCurrentPaymentAmount() {
        // 本次支付金额=报销明细费用累计-本次累计冲账金额(元)，最小为0
        let reimbursementAmount = new Decimal(this.model.reimbursementAmount || 0) // 报销明细费用累计
        let chargedAmount = new Decimal(this.model.chargedAmount || 0) // 本次累计冲账金额
        let currentPaymentAmount = reimbursementAmount.sub(chargedAmount).toNumber()
        this.$set(this.model, 'currentPaymentAmount', currentPaymentAmount)
      },
      handleOk() {
        this.projectVisible = false
        if (this.model.isRelProject == '0') {
          this.projectFlag = true
        } else {
          this.projectFlag = false
        }
        this.detailData = []
        this.reimbursementData = []
        this.$refs.travelDetails.dataSource = []
        this.$refs.travelReimbursements.dataSource = []
      },
      handleCancel() {
        this.projectVisible = false
        if (this.model.isRelProject == '0') {
          this.model.isRelProject = '1'
        } else {
          this.model.isRelProject = '0'
        }
      },
      projectInput(data) {
        if (this.detailData.length > 0 || this.reimbursementData.length > 0) {
          this.projectVisible = true
        } else {
          if (data == 0) {
            this.projectFlag = true
          } else {
            this.projectFlag = false
          }
        }
      },
      employeeInput(date) {
        if (date == 0) {
          this.employeeFlag = true
        } else {
          this.employeeFlag = false
        }
        this.$set(this.model, 'externalPersonnel', null)
      },
      travelDetailData(data) {
        this.detailData = data
        let count = 0
        this.detailData.forEach((item, index) => {
          count = count + item.amount
        })
        this.model.reimbursementAmount = count.toFixed(2)
        this.getCurrentPaymentAmount()
        this.model.thisAmount = new Decimal(this.model.thisAmount).toNumber().toFixed(2)
        this.model.thisAmount = (new Decimal(this.model.reimbursementAmount).add(new Decimal(this.model.kilometresAmount))).toNumber().toFixed(2)
        if (this.model.settleType == 2) {
          if (new Decimal(this.model.reimbursementAmount).toNumber() > new Decimal(this.model.outstandingAmount).toNumber()) {
            let amount = new Decimal(this.model.reimbursementAmount).sub(new Decimal(this.model.outstandingAmount))
            this.model.paymentAmount = amount.toNumber().toFixed(2)
          } else {
            this.model.paymentAmount = 0
          }
        }
      },
      travelReimbursementData(data) {
        this.reimbursementData = data
        let count = 0
        this.reimbursementData.forEach((item, index) => {
          count = count + item.amount
        })
        this.model.kilometresAmount = count.toFixed(2)
        this.model.thisAmount = new Decimal(this.model.thisAmount).toNumber().toFixed(2)
        this.model.thisAmount = (new Decimal(this.model.reimbursementAmount).add(new Decimal(this.model.kilometresAmount))).toNumber().toFixed(2)
        if (this.model.settleType == 2) {
          if (new Decimal(this.model.reimbursementAmount).toNumber() > new Decimal(this.model.outstandingAmount).toNumber()) {
            let amount = new Decimal(this.model.reimbursementAmount).sub(new Decimal(this.model.outstandingAmount))
            this.model.paymentAmount = amount.toNumber().toFixed(2)
          } else {
            this.model.paymentAmount = 0
          }
        }
      },
      back(item) {
        const res = item[0]
        let amount = new Decimal(res.amount).sub(new Decimal(res.repaymentAmount + res.travelReimbursementAmount + res.expenseReimbursementAmount))
        this.model.outstandingAmount = amount.toNumber().toFixed(2)
        if (new Decimal(this.model.reimbursementAmount).toNumber() > new Decimal(this.model.outstandingAmount).toNumber()) {
          let amount = new Decimal(this.model.reimbursementAmount).sub(new Decimal(this.model.outstandingAmount))
          this.model.paymentAmount = amount.toNumber().toFixed(2)
        } else {
          this.model.paymentAmount = 0
        }
      },
      settleTypeInput(data) {
        this.$refs['form'].clearValidate('settleType');
        if (data == 0) { // 转账
          this.$refs['form'].clearValidate('loanBillId');
          this.strikeBalance = false
          this.transferAccounts = true

          this.$set(this.model, 'loanBillId', null)
          this.$set(this.model, 'outstandingAmount', null)
          this.$set(this.model, 'paymentAmount', null)

          // 结算方式为转账时，收款户名为当前登录用户，收款开户行、收款账号为收款户名员工档案中的信息带出
          //  this.$set(this.model, 'accountName', this.userInfo().employee.name) //收款户名
          //  this.$set(this.model, 'bankName', this.userInfo().employee.bankName) //开户行
          //  this.$set(this.model, 'accountNo', this.userInfo().employee.bankCard) //银行卡号
        } else if (data == 2) { // 冲账
          this.$refs['form'].clearValidate('accountName');
          this.$refs['form'].clearValidate('bankName');
          this.$refs['form'].clearValidate('cnapsCode');
          this.$refs['form'].clearValidate('accountNo');
          this.transferAccounts = false
          this.strikeBalance = true

          this.$set(this.model, 'accountName', null)
          this.$set(this.model, 'bankName', null)
          this.$set(this.model, 'cnapsCode', null)
          this.$set(this.model, 'accountNo', null)
        } else {
          this.transferAccounts = false
          this.strikeBalance = false

          this.$set(this.model, 'loanBillId', null)
          this.$set(this.model, 'outstandingAmount', null)
          this.$set(this.model, 'paymentAmount', null)
          this.$set(this.model, 'accountName', null)
          this.$set(this.model, 'bankName', null)
          this.$set(this.model, 'cnapsCode', null)
          this.$set(this.model, 'accountNo', null)
        }
      },
      teamBack(item) {
        // 判断不为空
        if (!!this.model.teamId && item.length > 0) {
          // 判断团队是否变化
          if (this.teamIdBackups !== item[0].id) {
            if (this.model.isRelProject == 1 && this.detailData.length > 0 || this.reimbursementData.length > 0) {
              this.tdnd = item[0].tdnd
              const that = this;
              that.$confirm({
                title: '是否确认',
                content: '是否确认切换费用所属团队，此操作将会清空报销详情明细和自驾公里数补助明细中已填写的所有信息？',
                onOk() {
                  // 确认后进行改变
                  that.teamIdBackups = that.model.teamId
                  // that.model.teamYear = that.tdnd
                  // 清空子表数据
                  that.$refs.travelDetails.dataSource = []
                  that.$refs.travelReimbursements.dataSource = []
                  that.detailData = []
                  that.reimbursementData = []
                  // 清除借款单字段
                  that.$set(that.model, 'loanBillId', null)
                  that.$set(that.model, 'outstandingAmount', null)
                  that.$set(that.model, 'paymentAmount', null)
                  that.$refs.form.clearValidate('loanBillId');
                  // 清空金额
                  that.$set(that.model, 'reimbursementAmount', 0)
                  that.getCurrentPaymentAmount()
                  that.$set(that.model, 'kilometresAmount', 0)
                  that.$set(that.model, 'thisAmount', 0)
                  that.model.teamYear = item[0].tdnd;
                },
                onCancel() {
                  that.model.teamId = that.teamIdBackups
                }
              });
            } else {
              const that = this;
              this.teamIdBackups = item[0].id
              // this.model.teamYear = item[0].tdnd
              // 清空子表数据
              that.$refs.travelDetails.dataSource = []
              that.$refs.travelReimbursements.dataSource = []
              that.detailData = []
              that.reimbursementData = []
              // 清除借款单字段
              this.$set(this.model, 'loanBillId', null)
              this.$set(this.model, 'outstandingAmount', null)
              this.$set(this.model, 'paymentAmount', null)
              this.$refs.form.clearValidate('loanBillId');
              // 清空金额
              this.$set(that.model, 'reimbursementAmount', 0)
              this.getCurrentPaymentAmount()
              this.$set(that.model, 'kilometresAmount', 0)
              this.$set(that.model, 'thisAmount', 0)
              this.model.teamYear = item[0].tdnd;
            }
          }
        }
      },
      companyBack(item) {
        // 判断不为空
        const that = this;
        if (!!this.model.companyId && item.length > 0) {
          // 判断公司是否变化
          if (this.companyIdBackups !== item[0].id) {
            if (this.model.isRelProject == 1 && this.detailData.length > 0 || this.reimbursementData.length > 0) {
              that.$confirm({
                title: '是否确认',
                content: '是否确认切换申请公司，此操作将会清空报销详情明细和自驾公里数补助明细中已填写的所有信息？',
                onOk() {
                  // 确认后进行改变
                  that.companyIdBackups = that.model.companyId
                  // 清空子表数据
                  that.$refs.travelDetails.dataSource = []
                  that.$refs.travelReimbursements.dataSource = []
                  that.detailData = []
                  that.reimbursementData = []
                  // 清除借款单字段
                  that.$set(that.model, 'loanBillId', null)
                  that.$set(that.model, 'outstandingAmount', null)
                  that.$set(that.model, 'paymentAmount', null)
                  that.$refs.form.clearValidate('loanBillId');
                  // 清空金额
                  that.$set(that.model, 'reimbursementAmount', 0)
                  that.getCurrentPaymentAmount()
                  that.$set(that.model, 'kilometresAmount', 0)
                  that.$set(that.model, 'thisAmount', 0)
                },
                onCancel() {
                  that.model.companyId = that.companyIdBackups
                }
              });
            } else {
              this.companyIdBackups = item[0].id
              // 清空子表数据
              this.$refs.travelDetails.dataSource = []
              this.$refs.travelReimbursements.dataSource = []
              this.detailData = []
              this.reimbursementData = []
              // 清除借款单字段
              this.$set(this.model, 'loanBillId', null)
              this.$set(this.model, 'outstandingAmount', null)
              this.$set(this.model, 'paymentAmount', null)
              this.$refs.form.clearValidate('loanBillId');
              // 清空金额
              this.$set(that.model, 'reimbursementAmount', 0)
              this.getCurrentPaymentAmount()
              this.$set(that.model, 'kilometresAmount', 0)
              this.$set(that.model, 'thisAmount', 0)
            }
          }
        }
      },
      getBillNo () {
        const that = this
        getAction(this.url.gainBillNo).then((res) => {
          if (res.success) {
            that.model.billNo = res.result// 单据编号
            // that.model.bpmBizTitle = that.userName + '-' + that.model.billNo//标题
          }
        })
      },
      add () {
        console.log('执行了');
        
        this.userName = this.userInfo().empName;// 当前登录人名称
        this.modelDefault.proposer = this.userInfo().empId; // 当前登录人
        this.modelDefault.proposerDeptId = this.userInfo().deptId; // 当前登录人部门
        this.modelDefault.createTime = moment().format('YYYY-MM-DD HH:mm:ss');
        this.chargedInfoData = []
        this.getBillNo() // 获取单据编号
        this.edit(this.modelDefault);
      },
      async edit (record) {
        await this.$refs['form'].clearValidate();
        this.model = await Object.assign({}, record);
        this.model1 = await Object.assign({}, record);
        console.log(this.model,'sunkang');
        this.proposerDeptId = this.model.proposerDeptId;
        console.log(
          this.proposerDeptId,'表单'
        );
        
        
        if (this.model.settleType == 0) {
          this.transferAccounts = true
          this.strikeBalance = false
        } else if (this.model.settleType == 2) {
          this.strikeBalance = true
          this.transferAccounts = false
        } else {
          this.transferAccounts = false
          this.strikeBalance = false
        }
        if (this.model.id) {
          this.$refs.travelDetails.loadData(1, this.model.id)
          this.$refs.travelReimbursements.loadData(1, this.model.id)
        } else {
          this.$refs.travelDetails.dataSource = []
          this.$refs.travelReimbursements.dataSource = []
        }
        if (this.model.isRelProject == '0') {
          this.projectFlag = true
        } else {
          this.projectFlag = false
        }
        if (this.model.teamId) {
          this.teamIdBackups = this.model.teamId
        }
        if (this.model.companyId) {
          this.companyIdBackups = this.model.companyId
        }
        this.chargedInfoData = Object.assign([], this.model.chargedInfoList || [])
        this.visible = true;
      },
      // 渲染流程表单数据
      showFlowData() {
        if (this.formBpm === true) {
          let params = { id: this.formData.dataId };
          getAction(this.url.queryById, params).then((res) => {
            if (res.success) {
              this.edit(res.result);
            }
          });
        }
      },
      syncAdd(syncList) {
        this.$refs.travelReimbursements.addData(syncList)
      },
      // 支付金额数据判断
      handlePayAmount() {
        let model = this.model;
        let currentPaymentAmount = model.currentPaymentAmount
        let data = this.detailData;
        let amount = 0;
        data.forEach(item => {
          amount += item.amount;
        })
        amount = amount.toFixed(2);
        if (currentPaymentAmount > amount) {
          return true;
        }
        return false;
      },
      // 支付金额数据判断是否大于报销后的冲账剩余金额
      handlePayAndChargedAmount() {
        let model = this.model;
        let currentPaymentAmount = model.currentPaymentAmount
        let chargedAmount = model.chargedAmount
        let data = this.detailData;
        let amount = 0;
        data.forEach(item => {
          amount += item.amount;
        })
        let unChargedAmount = (amount - chargedAmount).toFixed(2)
        if (currentPaymentAmount > unChargedAmount) {
              return true;
            }
        return false;
      },
      submitForm(type) {
        const that = this;
        if (type == 'draft') {
          // 代表保存草稿不做校验
          this.submit(type)
        } else if (type == 'submit') {
          let str = ''
          for (var a = 0; a < this.reimbursementData.length; a++) {
            const item = this.reimbursementData[a]
            if (!item.startMileage) {
              str = str + (a + 1) + '，'
            }
          }
          if (str) {
            str = str.substr(0, str.length - 1)
            this.$message.warning('请完善自驾公里数补助明细中序号为【' + str + '】的明细信息！');
            this.$emit('unButtonDisable');
            return
          }
          // 触发表单验证
          this.$refs.form.validate(valid => {
            if (valid) {
              if ((this.model.relBillType == '1' || this.model.relBillType == '2') && this.chargedInfoData.length == 0) {
                that.$message.warning('请填写冲账信息');
                that.confirmLoading = false;
                that.$emit('unButtonDisable');
                return;
              }
              if (that.handlePayAmount()) {
                that.$message.warning('本次支付金额不能大于报销金额');
                that.confirmLoading = false;
                that.$emit('unButtonDisable');
                return;
              }
              if (that.handlePayAndChargedAmount()) {
                that.$message.warning('本次支付金额不能大于报销金额冲账后的剩余金额');
                that.confirmLoading = false;
                that.$emit('unButtonDisable');
                return;
              }
              that.submit(type)
            } else {
              that.$emit('unButtonDisable')
            }
          })
        } else {
          console.log('传参数，保存：draft，提交：submit')
        }
      },
      submit (type) {
        const that = this;
        this.isSubmit = false
        let teamName = filterMultiDictText(this.dictOptions['teamManager'], that.model.teamId + '')
        let createTime = this.getCreateTime()
        console.log('teamName', teamName)
        // 迭代16.7 取费用所属团队-申请人-申请日期（年月日）-金额（取报销明细费用累计）
        that.model.bpmBizTitle = (that.model.teamId ? teamName + '-' : '') + that.userInfo().empName + ' - ' + createTime + (that.model.reimbursementAmount ? '-' + that.model.reimbursementAmount : '') // 标题
        that.confirmLoading = true;
        let httpurl = '';
        let method = '';
        if (!this.model.id) {
          httpurl += this.url.add;
          method = 'post';
        } else {
          httpurl += this.url.edit;
          method = 'put';
        }
        this.model.travelDetail = this.detailData || []
        this.model.reimbursementDetail = this.reimbursementData || []
        this.model.chargedInfoList = this.chargedInfoData || []
        httpAction(httpurl, this.model, method).then((res) => {
          if (res.success) {
            that.$message.success(res.message);
            if (method == 'post') {
              that.model.id = res.result;
            }
            that.$emit('ok', type, that.model);
            let params = { id: that.formData.dataId };
            getAction(that.url.queryById, params).then((res) => {
              if (res.success) {
                that.model1 = res.result
                that.isSubmit = true
              }
            });
          } else {
            that.$message.warning(res.message);
            that.$emit('unButtonDisable');
          }
        }).catch((error) => {
          that.$emit('unButtonDisable', error);
        }).finally(() => {
          that.confirmLoading = false;
        })
      },
      // submitForm () {
      //   let str = ''
      //   for (var a = 0; a < this.reimbursementData.length; a++) {
      //     const item = this.reimbursementData[a]
      //     if (!item.startMileage) {
      //       str = str + (a+1) + '，'
      //     }
      //   }
      //   if (!!str) {
      //     str = str.substr(0, str.length - 1)
      //     this.$message.warning('请完善自驾公里数补助明细中序号为【' + str + '】的明细信息！');
      //     this.$emit('unButtonDisable');
      //     return
      //   }
      //   const that = this;
      //   // 触发表单验证
      //   this.$refs.form.validate(async valid => {
      //     if (valid) {
      //       let teamName = filterMultiDictText(this.dictOptions['teamManager'], that.model.teamId + '')
      //       let createTime = this.getCreateTime()
      //       //迭代16.7 取费用所属团队-申请人-申请日期（年月日）-金额（取报销明细费用累计）
      //       that.model.bpmBizTitle = teamName + ' - ' + that.userInfo().empName + ' - ' + createTime + ' - ' + that.model.reimbursementAmount//标题
      //       that.confirmLoading = true;
      //       let httpurl = '';
      //       let method = '';
      //       if (!this.model.id) {
      //         httpurl += this.url.add;
      //         method = 'post';
      //       } else {
      //         httpurl += this.url.edit;
      //         method = 'put';
      //       }
      //       this.model.travelDetail = this.detailData
      //       this.model.reimbursementDetail = this.reimbursementData
      //       httpAction(httpurl, this.model, method).then((res) => {
      //         if (res.success) {
      //           that.$message.success(res.message);
      //           that.$emit('ok');
      //         } else {
      //           that.$message.warning(res.message);
      //           that.$emit('unButtonDisable');
      //         }
      //       }).catch((error) => {
      //         that.$emit('unButtonDisable');
      //       }).finally(() => {
      //         that.confirmLoading = false;
      //       })
      //     } else {
      //       that.$emit('unButtonDisable');
      //     }

      //   })
      // },
      loanBillClick(id) {
        getAction(this.url.queryByLoanBillId, { id: id }).then((res) => {
          if (res.success) {
            const data = res.result
            this.visibleDetail = true
            this.$nextTick(() => {
              this.$refs.realForm.edit(data);
            });
          }
        })
      },
      handleCancelDetail() {
        this.visibleDetail = false
      },

      // 点击打印
      onPrint () {
        let print = new Print({
          el: '#travelContent',
          popTitle: '差旅报销详情 · 禾美环保',
          endCallback() {

          }
        })
      },
      async initDicts() {
        initDictOptions('erp_omc_team_manager,alias_name,id').then(async(res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'teamManager', res.result)
          }
        })
        initDictOptions('erp_finance_loan_bill,bill_no,id').then(async(res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'relLoanBillId', res.result)
          }
        })
      },
      getCreateTime() {
        let createTime = this.model.createTime;
        console.log(createTime)
        let date = createTime.substring(0, 10)
        return date.substring(0, 4) + '年' + date.substring(5, 7) + '月' + date.substring(8, 10) + '日';
      }
    }
  }
</script>
<style scoped>
.print_style{
  position: absolute;
  top: 0;
  z-index: -1111;
}
.ant-collapse-content {
  overflow: visible !important;
}
</style>
<style>
  @import "../../../../../utils/print.css";
</style>
